<template>
  <div style="flex:1;" class="flex auto">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' v-ref:criteria  @condition-changed='$parent.selfSearch'>
        <div novalidate class="form-inline" partial>
          <div class="form-group">
  				  <input type="text" class="form-control" v-model="model.f_meternumber"
  					condition="f_meternumber='{}'" placeholder='表号' v-next-el="aa" style="width:100px;">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_meter_phone"
            condition="f_meter_phone='{}'" style="width:100px;" placeholder='表电话' v-el:aa v-next-el="bb">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_isuse"
            condition="f_isuse='{}'" style="width:100px;" placeholder='使用状态' v-el:bb>
          </div>
          <div class="form-group">
            <button class="btn btn-success  width-60" @click="search()" >查询</button>
          </div>
          <div class="form-group">
            <!-- <file-upload class="my-file-uploader" name="myFile"
            action="rs/file/upload" tagname="上传多个文件" :headers="$parent.$parent.headers"></file-upload> -->
            <file-upload class="my-file-uploader" name="myFile"
            action="rs/file/upload" tagname="文件上传" :headers="$parent.$parent.headers" multiple v-ref:file></file-upload>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
  	  	<template partial='head'>
          <tr>
    				<th>序号</th>
    				<th>表号</th>
            <th>终端名称</th>
    				<th>表电话</th>
            <th>表口径</th>
    				<th>表通道类型</th>
    				<th>阀控标识</th>
    				<th>表通讯序号</th>
            <th>使用状态</th>
    			</tr>
        </template>
        <template partial='body'>
          <td style="text-align: center;">{{$index+1}}</td>
          <td>{{row.f_meternumber}}</td>
          <td>{{row.f_terminal_id}}</td>
          <td>{{row.f_meter_phone}}</td>
          <td>{{row.f_diameter}}</td>
          <td>{{row.f_meter_channel}}</td>
          <td>{{row.f_valvemark}}</td>
          <td>{{row.f_telecomm_no}}</td>
          <td>{{row.f_isuse}}</td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>
<script>
import { PagedList } from 'vue-client'
import * as Util from '../Util'

export default {
  title: '物联网表信息',
  data () {
    return {
      model: new PagedList('rs/sql/singleTable_OrderBy', 50, {items: '"*"', tablename: '"t_meterinfo"', orderitem: '"id"'}),
      headers: {'username': Util.f.name, 'blodid': Util.guid()}
    }
  },
  ready () {
    this.search()
  },
  methods: {
    search () {
      console.log(this.condition,this.model)
      this.model.search('1=1')

    },
    selfSearch (args) {

      this.model.search(args.condition, args.model)
    },
    fileparse (name, val) {
    }
  },
  events: {
    onFileUpload: function (file, res) {
      let data = {
        tablename: 't_meterinfo',
        filepath: res.path
      }
      this.$resetpost('rs/logic/import', {data: data}, {resolveMsg: '上传成功', rejectMsg: '上传失败'}).then((res) => {
        this.model.search('1=1')
      })
    }
  }
}

</script>
